from wxpy import *
import requests
import json

# bot = Bot()

# 图灵机器人的自动回复，根据info的消息来回复
def talks_robot(info = '你叫什么名字？'):
    api_url = 'http://www.tuling123.com/openapi/api'
    apikey = '84e42e8b167243f89668d5e71b865ca7'
    data = {
        'key': apikey,
        'info': info
    }
    req = requests.post(api_url, data=data).text
    replays = json.loads(req)['text']
    return replays

bot = Bot()

@bot.register()
def reply_my_friend(msg):
    message = '{}'.format(msg.text)
    replys = talks_robot(info=message)
    return replys

bot.start()

#print(talks_robot('我是谁？'))
# 在终端调试
# embed()